<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="module">
    import { DynamicLStorage } from "../../dist/storage/storage.js";

    const storage1 = new DynamicLStorage("login", {key: "userInfo"});
    storage1.set({
        zyy: "大傻逼"
    });
    console.log(storage1.get());
    storage1.add({
        "dasb": 123
    });
    console.log(storage1.get());
    const storage2 = new DynamicLStorage("login", {key: "userInfo12"});
    storage2.set(new Map([
        ["Song 1", "http://example.com/song1.mp3"],
        ["Song 2", "http://example.com/song2.mp3"],
        ["Song 3", "http://example.com/song3.mp3"]
    ]));
    console.log(storage2.get());
    storage2.add(new Map([["Song 4", "123456789"]]));
    storage2.add({"Song 5": "123456789"});
    console.log(storage2.get());
    const storage3 = new DynamicLStorage("login", {key: "userInfo1222"});
    console.groupCollapsed("三组");
    storage3.set([1, 2, 3, 4, 5, 6]);
    console.log(storage3.get());
    storage3.add(123);
    console.log(storage3.get());
    storage3.remove();
    console.log(storage3.get());
    console.groupEnd();
    const storage4 = new DynamicLStorage("login", {key: "userInfo122212"});
    console.groupCollapsed("四组");
    console.log(storage4.get());
    console.log(storage4.add({"Song 5": "123456789"}));

    console.log("删除");
    console.log(storage1.has());
    storage1.remove();
    console.log(storage1.get());
    console.log(storage1.has());

    console.log("分key");
    console.groupEnd();

    const storage5 = new DynamicLStorage("login");
    console.groupCollapsed("五组");
    storage5.set({
        zyy: "大傻逼"
    }, {key: "!!"});
    console.log(storage5.get("!!"));
    storage5.add({
        fuck: "you"
    }, {key: "!!"});
    console.log(storage5.get("!!"));
    console.groupEnd();
    // expires过期处理
    const storage6 = new DynamicLStorage("expires", {key: "banner"});
    console.group("expires过期处理");
    storage6.set({
        ttt: "测试有没有过期"
    }, {expires: 1});
    console.log(storage6.get());
    console.groupEnd();

    const storage7 = new DynamicLStorage("expires", {key: "banner112121"});
    console.group("expires过期处理2");
    storage7.set({
        ttt: "测试有没有过期dkoaskdoaskdoasjkdosa"
    }, {expires: (new Date()).getTime() + 3 * 1000});

    console.log(storage7.get());

    setTimeout(() => {
        console.log(storage7.get());
    }, 5 * 1000)
    console.groupEnd();
</script>
</body>
</html>
